<?php
/**
 * Description of chart
 *
 * @author  Freddy Yuswanto
 * @link    http://www.kohaci.com
 */
class Chart extends CI_Controller {

    public function  __construct() {
        //parent::Controller() ;
		parent::__construct();
    }

    public function index() {
        $this->load->helper(array('url','fusioncharts')) ;
        
        $graph_swfFile      = base_url().'public/flash/Column3D.swf' ;
        $graph_caption      = 'Harga Produk' ;
        $graph_numberPrefix = 'Rp.' ;
        $graph_title        = 'Penjualan Produk' ;
        $graph_width        = 450 ;
        $graph_height       = 250 ;

		
		
		
		
		
        // Store Name of Products
        $arrData[0][1] = "Product A";
        $arrData[1][1] = "Product B";
        $arrData[2][1] = "Product C";
        $arrData[3][1] = "Product D";
        $arrData[4][1] = "Product E";
        $arrData[5][1] = "Product F";

        //Store sales data
        $arrData[0][2] = 567500;
        $arrData[1][2] = 815300;
        $arrData[2][2] = 556800;
        $arrData[3][2] = 734500;
        $arrData[4][2] = 676800;
        $arrData[5][2] = 648500;

        $strXML = "<graph caption='".$graph_caption."' numberPrefix='".$graph_numberPrefix."' formatNumberScale='0' decimalPrecision='0'>";

        //Convert data to XML and append
	foreach ($arrData as $arSubData) {
            $strXML .= "<set name='" . $arSubData[1] . "' value='" . $arSubData[2] . "' color='".getFCColor()."' />";
        }
	//Close <chart> element
	$strXML .= "</graph>";
        
        $data['graph']  = renderChart($graph_swfFile, $graph_title, $strXML, "div" , $graph_width, $graph_height);

        $this->load->view('chart_view',$data) ;
    }
}
